#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>

/**
 * Luogu P1135: Strange Lift
 * The key to avoiding exceeding time limit is to record all visited floors.
 * Because if a state reaches a floor that is visited in a previous state, it
 * cannot have better solution than that state.
 */

struct State {
    int floor;
    int pushed;

    State(int floor, int pushed) : floor(floor), pushed(pushed) {}
};

int main() {
    // Input
    int n, from, to;
    scanf("%d %d %d", &n, &from, &to);
    if (from == to) {
        printf("0\n");
        return 0;
    }
    from--, to--;
    std::vector<int> num(n);
    for (int i = 0; i < n; i++) scanf("%d", &num[i]);

    // Use BFS to search
    int minPush = -1;
    std::queue<State> queue;
    queue.push(State(from, 0));
    std::vector<bool> visited(n, false);
    while (!queue.empty()) {
        // Pop a state from queue
        State s = queue.front();
        queue.pop();

        // Reach destination floor
        int floor = s.floor;
        if (visited[floor]) continue;  // visited this floor in previous state
        if (floor == to) {
            minPush = s.pushed;
            break;
        }
        visited[floor] = true;

        // Skip if pushed n - 1 times
        if (s.pushed == n - 1) continue;

        // Skip floor which cannot move up or down
        if (num[floor] == 0) continue;

        // Try up and down
        int down = floor - num[floor];
        if (down >= 0) queue.push(State(down, s.pushed + 1));
        int up = floor + num[floor];
        if (up < n) queue.push(State(up, s.pushed + 1));
    }
    printf("%d\n", minPush);

    return 0;
}